package com.u2ds.dss.tools;


import java.util.HashMap;
import java.util.Map;

/**
 * Created by Ethan.Yuan on 2017/1/23.
 */
public class SystemParamTool {

    /**
     * 参数与参数之间的分隔符
     */
    public static final String PARAM_SPLIT = ";";

    /**
     * 参数的属性与值之间的分隔符
     */
    public static final String PARAM_PROPERTY_SIGN = ":";

    public static Map<String, Object> getPropertyMap(String params){
        return SystemParamTool.getPropertyMap(params, new HashMap<String, Object>());
    }

    public static Map<String, Object> getPropertyMap(String params, Map<String, Object> propertyMap){
        try{
            String[] paramArray = params.split(SystemParamTool.PARAM_SPLIT);
            for(String entry : paramArray){
                String[] kvArray = entry.split(SystemParamTool.PARAM_PROPERTY_SIGN);
                propertyMap.put(kvArray[0], kvArray[1]);
            }
        }catch (Exception e){
            e.printStackTrace();
        }
        return propertyMap;
    }
}
